<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <button>添加</button>
  <script src="./axios.js"></script>
  <script>
    document.querySelector('button').addEventListener('click', function () {
      // 单击按钮之后，这里发送ajax请求，添加数据
      axios({
        method: 'POST',
        url: 'http://www.itcbc.com:3006/api/addbook',
        data: {
          bookname: '水浒',
          author: '鲁迅',
          publisher: '北京出版社',
          appkey: 'heshun'
        }
      }).then(({ data: res }) => {
        console.log(res) // 输出服务器返回的结果
      })
    })
  </script>
</body>

</html>